from classfile.constant_info import ConstantInfo


class ConstantUTF8Info(ConstantInfo):
    def __init__(self):
        super().__init__()
        self.string = ""

    def readInfo(self, clsReader):
        byteArray = clsReader.readU16()
        length = int.from_bytes(byteArray, "big")
        self.string = clsReader.readBytes(length).decode("UTF-8")

    def getString(self):
        return self.string

    def __str__(self):
        return self.string

